package android.team.app.ui;


import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.os.Bundle;
import android.team.app.R;
import android.widget.ImageButton;
import android.widget.TextView;

public class BaseActivity extends Activity implements OnClickListener{
	
	protected TextView tvHeader;
	protected ImageButton btHome;
	protected Context baseContext;	
	
	
	protected ProgressDialog progressDialog;	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.base_activity);
		
		baseContext = BaseActivity.this;
		
		loadUI();
		
	}
	
	//Xây dựng một hàm load ui riêng
	protected void loadUI(){
		
		tvHeader = (TextView)findViewById(R.id.tvHeader);
		btHome = (ImageButton)findViewById(R.id.btHome);
		btHome.setOnClickListener(this);
		
	}

	@Override
	public void onClick(View v) {
		if(v == btHome){
			startActivity(new Intent(baseContext, FirstActivity.class));
		}
		
	}
	
	//Xây dựng phương thức xử lý title
	protected void setTitleHeader(String title){
		tvHeader.setText(title);
	}
	
	public void showProgressDialog(String text){
		if(progressDialog == null){
			progressDialog = ProgressDialog.show(baseContext,null, text);
			progressDialog.setCancelable(false);
		}
	}
	
	public void hideProgressDialog(){		
		if(progressDialog != null){
			progressDialog.cancel();
			progressDialog = null;
		}
	}
	
}
